package com.roger.tool.utils;

import android.app.Activity;
import android.util.Log;

/**
 * 测试时打印用，统一 开关的 Log、 toast、 System.out.println 其中 错误级别 Log.e 的打印永远不关闭
 */
public class SGDebug {
	private static boolean isDebug = false;
	public static final String SGLOG = "SGLOG";

	public static final String PRINT = "SGLOG";

	public static void setDebugMode(boolean isDebug) {
		SGDebug.isDebug = isDebug;
	}

	public static boolean isDebug() {
		return isDebug;
	}

	// ======================================================
	// 有时希望在测试的时候弹的 toast，发包的时候也像这个 LOG 一样统一开关的，用此方法
	// ======================================================
	public static void toast(Activity pActivity, String text) {
		if (isDebug) {
			ToastUtil.showLong(pActivity, text);
		}
	}

	// ====================================================
	public static void systemOut(String message) {
		if (isDebug) {
			System.out.println(message);
		}
	}

	public static void i(String tag, String message) {
		if (isDebug) {
			Log.i(tag, ">>> " + message);
		}
	}

	public static void d(String tag, String message) {
		if (isDebug) {
			Log.d(tag, ">>> " + message);
		}
	}

	public static void v(String tag, String message) {
		if (isDebug) {
			Log.v(tag, ">>> " + message);
		}
	}

	public static void w(String tag, String message) {
		if (isDebug) {
			Log.w(tag, ">>> " + message);
		}
	}

	public static void e(String tag, String message) {
		if (isDebug) {
			Log.e(tag, ">>> " + message);
		}
	}

	// ===============================================

	public static void i(String message) {
		SGDebug.i(SGLOG, message);
	}

	public static void d(String message) {
		SGDebug.d(SGLOG, message);
	}

	public static void v(String message) {
		SGDebug.v(SGLOG, message);
	}

	public static void w(String message) {
		SGDebug.w(SGLOG, message);
	}

	public static void e(String message) {
		SGDebug.e(SGLOG, message);
	}

	// ======================================================
	// 传入 Object 可以顺带打印出 Object 的类名，方面看 此打印信息是在哪个类打印的
	private static String getObjectName(Object object) {
		String temp = object.getClass().getSimpleName() + "-->";
		return temp;
	}

	public static void systemOut(Object obj, String msg) {
		SGDebug.systemOut(getObjectName(obj) + msg);
	}

	public static void i(Object obj, String msg) {
		SGDebug.i(getObjectName(obj) + msg);
	}

	public static void d(Object obj, String msg) {
		SGDebug.d(getObjectName(obj) + msg);
	}

	public static void v(Object obj, String msg) {
		SGDebug.v(getObjectName(obj) + msg);
	}

	public static void w(Object obj, String msg) {
		SGDebug.w(getObjectName(obj) + msg);
	}

	public static void e(Object obj, String msg) {
		SGDebug.e(getObjectName(obj) + msg);
	}

	// ============================================
	// 以下的不受 控制，固定打印出来
	// ============================================

	public static void print_i(Object obj, String message) {
		SGDebug.print_i(getObjectName(obj) + message);
	}

	public static void print_d(Object obj, String message) {
		SGDebug.print_d(getObjectName(obj) + message);
	}

	public static void print_v(Object obj, String message) {
		SGDebug.print_v(getObjectName(obj) + message);
	}

	public static void print_w(Object obj, String message) {
		SGDebug.print_w(getObjectName(obj) + message);
	}

	public static void print_e(Object obj, String message) {
		SGDebug.print_e(getObjectName(obj) + message);
	}

	//
	public static void print_i(String message) {
		Log.i(PRINT, ">>> " + message);
	}

	public static void print_d(String message) {
		Log.d(PRINT, ">>> " + message);
	}

	public static void print_v(String message) {
		Log.v(PRINT, ">>> " + message);
	}

	public static void print_w(String message) {
		Log.w(PRINT, ">>> " + message);
	}

	public static void print_e(String message) {
		Log.e(PRINT, ">>> " + message);
	}

}
